<?php
/**
 * Created by PhpStorm.
 * User: liuhong
 * Date: 2018/12/3
 * Time: 下午2:25
 */

namespace Api\Controller;

use Api\Service\OrderService;
use Mobile\Controller\PayaliwapController;

class PayController extends LoginBaseController
{
    public function pay(){
        $pay_method=I('post.pay_method');
        $order_id=I('post.order_id');
        $where['order_id']=$order_id;
        $where['uid']=$this->uid;
        $orderInfo=OrderService::S()->findOrderDetailByWhere($where);
        if(!$orderInfo){
            $this->ajax(202,'订单信息查询失败');
        }
        switch ($pay_method){
            case 'alipay':
                $alipayCtl = new PayaliwapController();//new \Mobile\Controller\PayaliwapController();
                $payDetail = $alipayCtl->tradeAppPay($orderInfo);
                break;
            default:
                $alipayCtl = new PayaliwapController();//new \Mobile\Controller\PayaliwapController();
                $payDetail = $alipayCtl->tradeAppPay($orderInfo);
                break;
        }
        //dump($payDetail);die;
        if($payDetail){
            $this->ajax(200,'success',$payDetail);
        }

    }

    public function payT(){
        $order_id=I('post.order_id');
        $orderInfo=OrderService::S()->findOrderDetail($order_id);
        //dump($orderInfo);die;
        $alipayCtl = new PayaliwapController();//new \Mobile\Controller\PayaliwapController();
        $payDetail = $alipayCtl->tradeAppPay($orderInfo);
        $this->ajax(200,'success',$payDetail);
    }


}